﻿using KTD.Web.BLL;
using KTD.Web.Models;
using KTD.Web.Models.VD;
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using XXS.Common.ControllerExt;

namespace AXKC.DamMonitor.Web.Areas.WeChat.Controllers
{
    public class AuthorizeController : BaseController
    {
        //[HttpPost]
        public ActionResult Verify(WeChatAuthorizeDto im)
        {
            if (ModelState.IsValid)
            {
                Member user;
                WeChatVerifyResultDto result;

                var res = MF.WeChatAuthorizeManager.Verify(im, out user, out result);
                return this.JsonNet(new { success = true, data=new { openid = result?.OpenId,memberid=user.Id,mobile=user.Mobile} });
            }
            return this.JsonNet(new { success = false, msg = "验证不通过" });
        }

        [HttpPost]
        public ActionResult Regester(RegisterD im)
        {
            try
            {
                var user = MF.MemberManager.Register(im);
                return this.JsonNet(new { success = true });
            }
            catch (Exception ex)
            {
                return this.JsonNet(new { success = false, msg = ex.Message });
            }

        }
    }
}